package com.shuwen.gcdj.common.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * @author hardy.zhang
 * @version V1.0
 * @Package com.shuwen.user.common.enums
 * @date 11/18/21 1:49 PM
 */
public enum AuthType {
    /**
     * 不做校验
     **/
    NONE(99, "不做校验", "trustedAuth"),

    /**
     * 通过redis校验用户Token，同时将UserCacheBasic加入request
     **/
    TOKEN(0, "通过redis校验用户Token，同时将UserCacheBasic加入request", "tokenAuth"),

    /**
     * 通过redis校验用户Token，同时将UserCacheDetail&UserCacheBasic加入request
     **/
    DETAILTOKEN(1, "通过redis校验用户Token，同时将UserCacheDetail&UserCacheBasic加入request", "detailTokenAuth"),

    /**
     * 通过JWT校验用户Token
     **/
    JWT(2, "通过JWT校验用户Token", "jwtAuth"),

    /**
     * 校验AKSK
     **/
    AKSK(3, "校验AKSK", "akskAuth"),

    /**
     * 校验OAuth token
     **/
    OAUTH(4, "校验OAuth token", "oauthTokenAuth"),

    /**
     * 通过redis校验游客用户TEMPToken，同时将UserCacheBasic加入request
     **/
    TEMPTOKEN(5, "通过redis校验游客用户TEMPToken，同时将UserCacheBasic加入request", "tempTokenAuth"),

    /**
     * 校验临时票据
     **/
    TICKET(6, "校验临时票据", "ticketAuth"),

    /**
     * 项目自定义校验
     **/
    CUSTOM(7, "项目自定义校验", "customAuth");

    private final int value;
    private final String description;
    private final String defaultBeanName;

    /**
     * getValue
     *
     * @return int
     */
    public int getValue() {
        return value;
    }

    /**
     * getDescription
     *
     * @return String
     */
    public String getDescription() {
        return description;
    }

    /**
     * getDefaultBeanName
     *
     * @return String
     */
    public String getDefaultBeanName() {
        return defaultBeanName;
    }

    /**
     * Constructor
     *
     * @param value           int
     * @param description     String
     * @param defaultBeanName String
     */
    AuthType(int value, String description, String defaultBeanName) {
        this.value = value;
        this.description = description;
        this.defaultBeanName = defaultBeanName;
    }


    public static AuthType[] namesOf(String[] values) {
        List<AuthType> result = new ArrayList<>(values.length);
        for (String val:values) {
            AuthType auth = AuthType.valueOf(val.toUpperCase());
            result.add(auth);
        }

        return result.toArray(new AuthType[result.size()]);
    }
}
